package cn.ctodb.wxmp.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * A MessageTp.
 */
@Entity
@Table(name = "message_tp")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "messagetp")
public class MessageTp implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "template_id")
    private String templateId;

    @Column(name = "url")
    private String url;

    @Size(max = 4000)
    @Column(name = "data", length = 4000)
    private String data;

    @ManyToOne
    private UserInfo touser;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTemplateId() {
        return templateId;
    }

    public MessageTp templateId(String templateId) {
        this.templateId = templateId;
        return this;
    }

    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }

    public String getUrl() {
        return url;
    }

    public MessageTp url(String url) {
        this.url = url;
        return this;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getData() {
        return data;
    }

    public MessageTp data(String data) {
        this.data = data;
        return this;
    }

    public void setData(String data) {
        this.data = data;
    }

    public UserInfo getTouser() {
        return touser;
    }

    public MessageTp touser(UserInfo userInfo) {
        this.touser = userInfo;
        return this;
    }

    public void setTouser(UserInfo userInfo) {
        this.touser = userInfo;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MessageTp messageTp = (MessageTp) o;
        if (messageTp.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, messageTp.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "MessageTp{" +
            "id=" + id +
            ", templateId='" + templateId + "'" +
            ", url='" + url + "'" +
            ", data='" + data + "'" +
            '}';
    }
}
